package com.srd.phone.bean;

import android.text.TextUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

public class BorrowPeopleInfo implements Serializable {

    public String nm;
    public String address;
    public String aid;
    public String idCard;

    public static BorrowPeopleInfo parse(String json) {
        BorrowPeopleInfo info = new BorrowPeopleInfo();
        try {
            JSONObject jsonObject = new JSONObject(json);
            info.nm = jsonObject.optString("nm");
            info.address = jsonObject.optString("address");
            info.aid = jsonObject.optString("aid");
            info.idCard = jsonObject.optString("idCard");
            if (!TextUtils.isEmpty(info.nm) && info.nm.contains("null")) {
                info.nm = info.nm.replace("null", "");
            }
            if (!TextUtils.isEmpty(info.idCard) && info.idCard.contains("null")) {
                info.idCard = info.idCard.replace("null", "");
            }
            if (!TextUtils.isEmpty(info.aid) && info.aid.contains("null")) {
                info.aid = info.aid.replace("null", "");
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return info;
    }
}
